/**
 * 储存空间换算
 */
export function FileSizeConvert(size: number): string {
    let data: string = "";
    if (size < 0.1 * 1024) { //如果小于0.1KB转化成B
        data = size.toFixed(2) + "B";
    } else if (size < 0.1 * 1024 * 1024) {//如果小于0.1MB转化成KB
        data = (size / 1024).toFixed(2) + "KB";
    } else if (size < 0.1 * 1024 * 1024 * 1024) { //如果小于0.1GB转化成MB
        data = (size / (1024 * 1024)).toFixed(2) + "MB";
    } else { //其他转化成GB
        data = (size / (1024 * 1024 * 1024)).toFixed(2) + "GB";
    }
    let sizestr: string = data + "";
    let len: number = sizestr.indexOf("\.");
    let dec: string = sizestr.substring(len + 1, len + 3);
    if (dec === "00") {//当小数点后为00时 去掉小数部分
        return sizestr.substring(0, len) + sizestr.substring(len + 3, len + 5);
    }
    return sizestr;
}

